package com.gotloop.dao;

import java.util.Date;
import java.util.List;

import com.gotloop.jdo.Loop;

/**
 * Loop Data Access Object.
 * @author jibhaine
 *
 */
public interface LoopDAO extends AbstractDAO<Loop, String> {

	/**
	 * Get One loop by its Title.
	 * @param url the Loop title
	 * @return the matching Loop
	 */
	Loop getLoopByTitle(String url);
	
	/**
	 * Get a List of Loops with the specified tag.
	 * @param tag			requested tag
	 * @param startIndex	start index
	 * @param itemsPerPage	number of loops per page
	 * @return				a List of Loop, ordered by date
	 */
	List<Loop> getLoopsByTag(String tag, int startIndex, int itemsPerPage);

	/**
	 * Get a List of Loops from the specified author.
	 * @param userName		the loop author name
	 * @param startIndex	start index
	 * @param itemsPerPage	number of loops per page
	 * @return				a List of Loop, ordered by date
	 */
	List<Loop> getLoopsByAuthor(String userName, int startIndex, int itemsPerPage);

	/**
	 * Get a List of Loops created the specified day.
	 * @param dayDate		Date of creation of the loops
	 * @param startIndex	start index
	 * @param itemsPerPage	number of loops per page
	 * @return				a List of Loop, ordered by date
	 */
	List<Loop> getLoopsByDay(Date dayDate, int startIndex, int itemsPerPage);

	/**
	 * Get a List of Loops created the specified month.
	 * @param monthDate		Date of creation of the loops
	 * @param startIndex	start index
	 * @param itemsPerPage	number of loops per page
	 * @return				a List of Loop, ordered by date
	 */
	List<Loop> getLoopsByMonth(Date monthDate, int startIndex, int itemsPerPage);

	/**
	 * Return the number of loops created at the specified year.
	 * @param yearDate	year
	 * @return			number of loops 0 if none
	 */
	Long howManyLoopsThisYear(Date yearDate);

	/**
	 * Return the number of loops created at this month.
	 * @param monthDate	month
	 * @return			number of loops 0 if none
	 */
	Long howManyLoopsThisMonth(Date monthDate);

	/**
	 * Return the number of loops created at this day.
	 * @param dayDate	day
	 * @return			number of loops 0 if none
	 */
	Long howManyLoopsThisDay(Date dayDate);

	/**
	 * Return the number of loops with this tag.
	 * @param tag		the tag
	 * @return			number of loops 0 if none
	 */
	Long howManyLoopsForThisTag(String tag);
}
